package com.cloud.code.单例模式.枚举单例;

import java.lang.reflect.InvocationTargetException;

public class Sun {

    private Sun() {
    }

    public static Sun getInstance() {
        return SunEnum.HOLDER.sun;
    }

    public enum SunEnum {

        HOLDER;


        private Sun sun;

        SunEnum() {
            sun = new Sun();
        }
    }

}

class main{

    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
//        Sun instance = Sun.getInstance();
//        System.out.println(instance);
//        Class sunClass = Sun.class;
//        Constructor declaredConstructor = sunClass.getDeclaredConstructor();
//        declaredConstructor.setAccessible(true);
//        Sun sun = (Sun) declaredConstructor.newInstance();
//
//        System.out.println(sun.getInstance());
    }
}
